/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package xmldatabase;

/**
 *
 * @author betty
 */
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class VisitMySql {

    // 连接对象
    private Connection conn;
    // 传递sql语句
    private Statement stt;
    // 结果集
    private ResultSet set;

    // 查询
    public void Select() {
        try {
            conn = DBConnection.getConnection();
            if (conn == null) {
                return;
            }
            String Sql = "select * from news";
            stt = conn.createStatement();
            set = stt.executeQuery(Sql);
            while (set.next()) {

                System.out.println("职位编码:" + set.getString(1) + "\t手机号码:"
                        + set.getString(2) + "\t电子邮箱:" + set.getString(3) + "\t性别:"
                        + set.getString(4) + "\t编号:"
                        + set.getString(5) + "\t姓名:"
                        + set.getString(6));

            }

        } catch (Exception e) {
        } finally {
            try {
                set.close();
                conn.close();
            } catch (Exception e2) {
            }
        }
    }
}
